import fs from 'fs';

/**
 * 从Git仓库URL中提取仓库名称
 * @param url Git仓库URL
 * @returns 仓库名称
 */
export function getRepoName(url: string): string {
  const repoName = url.split('/').slice(-1)[0].replace('.git', '');
  return repoName;
}

export async function pathIsOk(path: string): Promise<boolean> {
  try {
    await fs.promises.access(path, fs.constants.F_OK);
    return true;
  } catch (err) {
    return false;
  }
}
